<html>
	{% include "../common_head.html" %}
	<body>
	{% include "../common_menus.html" %}
		<div id="content">
		
		<div id="rakontu_form_style" class="rakontu_form">
		<form action="/{{dir_visit}}/{{url_entry}}
		{% if entry %}
			?{{entry.urlQuery}}
		{% else %}
			?{{rakontu.urlQuery}}
		{% endif %}
		{% if bookmark %}&{{url_query_bookmark}}={{bookmark}}{% endif %}
		" method="post" enctype="multipart/form-data">
		
			{% if entry %}
			 	<h3>{{entry.title}} ({{entry_type_display}})</h3>
			{% else %}
				<h3>{{template_new}} {{entry_type_display|capfirst}}</h3>
			{% endif %}
			<fieldset>
			
			{% ifequal entry_type "topic" %}
				{% if entry %}
					<p>{{template_name}}
				{% else %}
					<p>{{template_please_give_name_to_your_topic}}</p><p>
				{% endif %}
				&nbsp; <input type="text" name="title" size="60" value="
					{% if entry %}
						{% if version_title %}
							{{version_title}}
						{% else %}
							{{entry.title}}
						{% endif %}
					{% endif %}
					" maxlength="{{maxlength_name}}"/></p>
			{% endifequal %}
			
			{% if not entry %}
				{% ifequal entry_type "story" %}
					{{template_tell_new_story}} 
				{% endifequal %}
				{% ifequal entry_type "pattern" %}
					{{template_describe_new_pattern}}
				{% endifequal %} 
				{% ifequal entry_type "collage" %}
					{{template_describe_new_collage}}
				{% endifequal %}
				{% ifequal entry_type "topic" %}
					{{template_describe_new_topic}}
				{% endifequal %}
				{% ifequal entry_type "resource" %}
					{{template_text_for_new_resource}}
				{% endifequal %}
			{% endif %}
			 
			{% if entry and version %}
				<p><b>{{template_restoring_version_from}} 
				{% if current_member.timeFormat %}
					{{version.created|timeZone:current_member.timeZoneName|time:current_member.timeFormat}} 
				{% endif %}
				{{version.created|timeZone:current_member.timeZoneName|date:current_member.dateFormat}}</b></p>
			{% endif %}
			<table style="width:100%; border:none">
			<tr><td class="noborder">
				{% if entry %}
					{% if version_text %}
						<textarea name="text" rows="20" cols="60">{{version_text}}</textarea>
					{% else %}
						<textarea name="text" rows="20" cols="60">{{entry.text}}</textarea>
					{% endif %}
				{% else %}
					<textarea name="text" rows="20" cols="60"></textarea>
				{% endif %}
			</td><td class="noborder" width="80">
			<p>{{template_interpret_as}} {{"interpreting_texts"|tip}}</p>
				<select name="text_format">
				{% for i in text_formats|makeRangeFromListLength %}
					<option value="{{text_formats|listLookup:i}}" 
					{% if entry %}
						{% if version_format %}
							{% if text_formats|listLookup:i|equalTest:version_format %}
								selected="selected"
							{% endif %}
						{% else %}
							{% if text_formats|listLookup:i|equalTest:entry.text_format %}
								selected="selected"
							{% endif %}
						{% endif %}
					{% else %}
						{% if text_formats|listLookup:i|equalTest:current_member.preferredTextFormat %}
							selected="selected"
						{% endif %}
					{% endif %}
					>{{text_formats_display|listLookup:i}}</option>
				{% endfor %}
				</select>
			</td></tr></table>
			
			{% ifnotequal entry_type "topic" %}
				{% if entry %}
					<p>{{template_name}}
				{% else %}
					<p>{{template_please_give_name_to_your}} {{entry_type_display}}.</p><p>
				{% endif %}
				&nbsp; <input type="text" name="title" size="60" value="
					{% if entry %}
						{% if version_title %}
							{{version_title}}
						{% else %}
							{{entry.title}}
						{% endif %}
					{% endif %}
					" maxlength="{{maxlength_name}}"/></p>
			{% endifnotequal %}
			
			{% if not entry %}
				{% include "../common_attribution.html" %}
			{% else %}
				{% ifequal entry.creator.key current_member.key %}
					{% include "../common_attribution.html" %}
				{% endifequal %}
				{% ifequal entry.liaisonIfOfflineMember.key current_member.key %}
					{% include "../common_attribution.html" %}
				{% endifequal %}
			{% endif %}

			{% if link_item_from %}
				{% ifequal link_type "retell" %}
					<p>{{template_since_you_retold}} {{link_item_from.linkString}}:</p>
				{% endifequal %} 
				{% ifequal link_type "remind" %}
					<p>{{template_since_you_reminded}} {{link_item_from.linkString}}:</p>
				{% endifequal %}
				{% ifequal link_type "respond" %}
					<p>{{template_since_you_responded}} {{link_item_from.linkString}}:</p>
				{% endifequal %}
				<fieldset>
				{% ifequal link_type "retell" %}
					<p>{{template_comment_on_retold_link}}</p>
				{% endifequal %}
				{% ifequal link_type "remind" %}
					<p>{{template_comment_on_reminded_link}}</p>
				{% endifequal %}
				{% ifequal link_type "respond" %}
					<p>{{template_comment_on_responded_link}}</p>
				{% endifequal %}
				<p><input type="text" name="link_comment" value="" size="80" maxlength="{{maxlength_subject_or_comment}}"></p>
				<input type="hidden" name="link_type" value="{{link_type}}">
				<input type="hidden" name="link_item_from" value="{{link_item_from.key}}">
				</fieldset>
			{% endif %}
			
			{% ifequal entry_type "resource" %}
				<p>{{template_since_this_is_a_resource}}:</p>
				<fieldset>
				<p>{{template_which_resource_options_apply}}</p>
				<p>
				<input type="checkbox" name="resourceForHelpPage" value="yes" 
				{% if entry %}
					{% if entry.resourceForHelpPage %}
						checked="checked"
					{% endif %}
				{% endif %}
				id="resourceForHelpPage">
				<label for="resourceForHelpPage">{{template_yes_is_help_resource}}</label>
				</p>
				<p>
				<input type="checkbox" name="resourceForNewMemberPage" value="yes" 
				{% if entry %}
					{% if entry.resourceForNewMemberPage %}
						checked
					{% endif %}
				{% endif %}
				id="resourceForNewMemberPage">
				<label for="resourceForNewMemberPage">{{template_yes_is_new_member_resource}}</label>
				</p>
				{% if current_member.isManagerOrOwner %}
					<p>
					<input type="checkbox" name="resourceForManagersAndOwnersOnly" value="yes" 
					{% if entry %}
						{% if entry.resourceForManagersAndOwnersOnly %}
							checked
						{% endif %}
					{% endif %}
					id="resourceForManagersAndOwnersOnly">
					<label for="resourceForManagersAndOwnersOnly">{{template_yes_manager_only_resource}}</label>
					</p>
				{% endif %}
				<p>{{template_what_category_should_this_resource_be_in}}</p>
				{% if categories_in_use %}
					<p>&nbsp; &nbsp; <select name="categoryIfResource_list">
						<option value="none">({{template_choose}})</option>
						{% for category in categories_in_use %}
							<option value="{{category}}"
							{% ifequal category entry.categoryIfResource %}
								selected="selected"
							{% endifequal %}
							>{{category}}</option>
						{% endfor %}
						</select>
					{{template_or_enter_a_new_category_here}}:
				{% endif %}
				<input type="text" name="categoryIfResource_entered" value="" size="30" maxlength="{{maxlength_name}}"></p>
				</fieldset>
			{% endifequal %}
				
			</fieldset>
			
			{% if entry and versions %}
				<p>{{template_load_version}}
				<select name="versionToLoad">
				<option value="none">({{template_choose}})</option>
				{% for aVersion in versions %}
					<option value="{{aVersion.getKeyName}}">{{aVersion.title}} - 
						{% if current_member.timeFormat %}
							{{aVersion.created|timeZone:current_member.timeZoneName|time:current_member.timeFormat}} 
						{% endif %}
						{{aVersion.created|timeZone:current_member.timeZoneName|date:current_member.dateFormat}}
						({{aVersion.text|upTo:60}})
						</option>
				{% endfor %}
				</select>
				<input type="submit" name="loadVersion" value="{{button_load_version}}" class="button_small"
						{% if current_member.showButtonTooltips %}
							title="{{"loading_versions"|buttonTooltip}}"
						{% endif %}
				>
				{{"text_versions"|info}}</p>
			{% endif %}
			
			<p>
			{% if questions %}
				{% if not entry %}
					{% include "../common_questions.html" %}
				{% else %}
					{% ifequal entry.creator.key current_member.key %}
						{% include "../common_questions.html" %}
					{% endifequal %}
					{% ifequal entry.creator.liaisonIfOfflineMember.key current_member.key %}
						{% include "../common_questions.html" %}
					{% endifequal %}
				{% endif %}
			{% endif %}
			
		{% ifequal entry_type "collage" %}
			{% if included_links_outgoing %}
				<h3>{{template_stories_included_in_collage}}</h3>
				<fieldset>
		      	<table border="0" cellpadding="4" cellspacing="0">
		      	<tr>
		      		<th>{{template_name}}</th>
		      		<th>{{template_first_part_of_text}}</th>
		      		<th>{{template_published}}</th>
		      		<th>{{template_link_comment}}</th>
		      		<th>{{template_remove}}?</th>
		      		</tr>
		      		{% for link in included_links_outgoing %}
		  				<tr>
		  				<td>{{link.itemTo.linkString}}</a></td>
			  			<td>{{link.itemTo.text_formatted|upTo:current_member.shortDisplayLength|orNbsp}}</td>
	        			<td>{{link.itemTo.published|timeZone:current_member.timeZoneName|date:current_member.dateFormat}}</td>
		  				<td><input type="text" name="linkComment|{{link.key}}" value="{{link.comment}}" size="40" maxlength="{{maxlength_subject_or_comment}}"/></td>
		  				<td width="80">
		  					<input type="checkbox" name="removeLink|{{ link.key }}" value="yes" id="removeLink|{{ link.key }}"/>
							<label for="removeLink|{{ link.key }}">{{template_remove}}</label>
		  					</td>
		  				</tr>
		      		{% endfor %}
		      	</table>
		      	</fieldset>
	      {% endif %}
  		{% if collage_entries %}
	  		<h3>{{template_add_stories_to_the_collage}}</h3>
				<fieldset>
		      	<table border="0" cellpadding="4" cellspacing="0">
		      	<tr>
		      		<th>{{template_name}}</th>
		      		<th>{{template_first_part_of_text}}</th>
					<th>{{template_published}}</th>
		      		<th width="80">{{template_add_link}}?</th>
		      		<th>{{template_link_comment}}</th>
					</tr>
	      		{% for anEntry in collage_entries %}
	      			<tr>
	      			 <td>{{anEntry.linkString}}</td>
	      			 <td>{{anEntry.text_formatted|upTo:current_member.shortDisplayLength|orNbsp}}</td>
	        		 <td>{{anEntry.published|timeZone:current_member.timeZoneName|date:current_member.dateFormat}}</td>
	      			<td>
	      			<input type="checkbox" name="addLink|{{anEntry.key}}" value="yes" id="addLink|{{anEntry.key}}"/>
					<label for="addLink|{{anEntry.key}}">{{template_add_link}}</label>
	      			</td>
	      			<td><input type="text" name="linkComment|{{anEntry.key}}" value="" size="40"/></td>
	      			 </tr>
	      		{% endfor %}
			    </table>	      	
				
				<p>
				{% if previous %}
					 {% if entry %}
					 	<a href="/{{dir_visit}}/{{url_collage}}?{{entry.urlQuery}}&{{url_query_bookmark}}={{previous}}">{{template_newer}} {{template_stories|lower}}</a>
					 {% else %}
					 	<a href="/{{dir_visit}}/{{url_collage}}?{{rakontu.urlQuery}}&{{url_query_bookmark}}={{previous}}">{{template_newer}} {{template_stories|lower}}</a>
					 {% endif %}
				{% endif %}	
				{% if previous and next %} ... {% endif %}
				{% if next %}
					{% if entry %}
					 	<a href="/{{dir_visit}}/{{url_collage}}?{{entry.urlQuery}}&{{url_query_bookmark}}={{next}}">{{template_older}} {{template_stories|lower}}</a>
					{% else %}
					 	<a href="/{{dir_visit}}/{{url_collage}}?{{rakontu.urlQuery}}&{{url_query_bookmark}}={{next}}">{{template_older}} {{template_stories|lower}}</a>
					{% endif %}
				{% endif %}	
				 </fieldset>
		{% else %}
			<p>{{template_no_stories_to_add_to_collage}}</p>
		{% endif %}
	  
	  {% endifequal %}
	  
		{% ifequal entry_type "pattern" %}
			{% if referenced_links_outgoing %}
				<h3>{{template_filters_referred_to_by_this_pattern}}</h3>
				<fieldset>
		      	<table border="0" cellpadding="4" cellspacing="0">
		      	<tr>
		      		<th>{{template_name}}</th>
		      		<th>{{template_description}}</th>
		      		<th>{{template_link_comment}}</th>
		      		<th>{{template_remove}}?</th>
		      		</tr>
		      		{% for link in referenced_links_outgoing %}
		  				<tr>
		  				<td>{{link.itemTo.linkString}}</a></td>
		  				<td>{{link.itemTo.text_formatted|upTo:current_member.shortDisplayLength|orNbsp}}</td>
		  				<td><input type="text" name="linkComment|{{link.key}}" value="{{link.comment}}" size="60" maxlength="{{maxlength_subject_or_comment}}"/></td>
		  				<td width="80">
		  					<input type="checkbox" name="removeLink|{{ link.key }}" value="yes" id="removeLink|{{ link.key }}"/>
							<label for="removeLink|{{ link.key }}">{{template_remove}}</label>
		  					</td>
		  				</tr>
		      		{% endfor %}
		      	</table>
		      	</fieldset>
	      {% endif %}
			<h3>{{template_add_filters_to_the_pattern}}</h3>
			{% if filters_that_can_be_added_to_pattern %}
				<fieldset>
		      	<table border="0" cellpadding="4" cellspacing="0">
		      	<tr>
		      		<th>{{template_name}}</th>
		      		<th>{{template_description}}</th>
					<th>{{template_created}}</th>
		      		<th width="80">{{template_add_link}}?</th>
		      		<th>{{template_link_comment}}</th>
					</tr>
	      		{% for filter in filters_that_can_be_added_to_pattern %}
	      			<tr>
	      			 <td>{{filter.linkString}}</td>
	      			 <td>{{filter.description|orNbsp}}</td>
	        		 <td>{{filter.created|timeZone:current_member.timeZoneName|date:current_member.dateFormat}}</td>
	      			<td>
	      			<input type="checkbox" name="addLink|{{filter.key}}" value="yes" id="addLink|{{filter.key}}"/>
					<label for="addLink|{{filter.key}}">{{template_add_link}}</label>
	      			</td>
	      			<td><input type="text" name="linkComment|{{filter.key}}" value="" size="40"/></td>
	      			 </tr>
	      		{% endfor %}
			    </table>	      	
	      	</fieldset>
	      	{% else %}
	      		<ul><li class="nobullet">{{template_no_shared_filters_available}}</li></ul>
	      	{% endif %}
	  {% endifequal %}
	  
		{% if not entry %}
			<h3>{{template_would_you_like_to_make_a_comment_on_this}} {{entry_type}}?</h3>
			<fieldset>
			<p>{{template_comment_subject}} <input type="text" name="comment_shortString" size="80" value="" maxlength="{{maxlength_subject_or_comment}}"/></p>
			<table style="width:100%; border:none">
			<tr><td class="noborder">
			<textarea name="comment_longString" rows="3" cols="60"></textarea>
			</td><td class="noborder" width="80">
			<p>{{template_interpret_as}} {{"interpreting_texts"|tip}}</p>
				<select name="comment_longString_format">
				{% for i in text_formats|makeRangeFromListLength %}
					<option value="{{text_formats|listLookup:i}}" 
					{% if text_formats|listLookup:i|equalTest:current_member.preferredTextFormatt %}
						selected="selected"
					{% endif %}
					>{{text_formats_display|listLookup:i}}</option>
				{% endfor %}
				</select>
			</td></tr></table>
			</fieldset>
	
			<h3>{{template_would_you_like_to_make_a_request_about_this}} {{entry_type}}?</h3>
			<fieldset>
			{{template_request_subject}} <input type="text" name="request_shortString" size="80" value="" maxlength="{{maxlength_subject_or_comment}}"/>
			<table style="width:100%; border:none">
			<tr><td class="noborder">
			<textarea name="request_longString" rows="3" cols="60"></textarea>
			</td><td class="noborder" width="80">
			<p>{{template_interpret_as}}</p>
				<select name="request_longString_format">
				{% for i in text_formats|makeRangeFromListLength %}
					<option value="{{text_formats|listLookup:i}}" 
					{% if text_formats|listLookup:i|equalTest:current_member.preferredTextFormatt %}
						selected="selected"
					{% endif %}
					>{{text_formats_display|listLookup:i}}</option>
				{% endfor %}
				</select>
			</td></tr></table>
			<p>{{template_what_is_request_type}}
			<select name="typeIfRequest">
				<option name="none">({{term_choose}})</option>
				{% for type in request_types %}
					<option value="{{type}}">{{type}}</option>
				{% endfor %}
				</select></p>
			</fieldset>

			<h3>{{template_would_you_like_to_add_some_tags_to_this}} {{entry_type}}?</h3>
			<fieldset>
			<p>
			{% for i in num_tags_in_tag_set|makeRange %}
				{% if already_there_tags %}
					<select name="alreadyThereTag{{i}}">
					<option value="none">({{term_choose}})</option>
					{% for tag in already_there_tags %}
						{% if tag|orNothing %}
							<option value="{{tag}}">{{tag}}</option>
						{% endif %}
					{% endfor %}
					</select>
				{% endif %}
				<input type="text" name="tag{{i}}" size="15" value="" maxlength="{{maxlength_tag_or_choice}}"/>
				<br/> 
			{% endfor %}
			</p>
			</fieldset>

		{% endif %}
			
			<p>
			<center>
			{% if entry %}
				{% if entry.inBatchEntryBuffer %}
					<input type="submit" name="save|{{entry_type}}" value="{{button_save_changes_and_return}}" class="button">
					<input type="submit" name="preview|{{entry_type}}" value="{{button_preview}}" class="button">
				{% else %}
					{% if entry.draft %}
						<input type="submit" name="save|{{entry_type}}" value="{{button_save_draft}}" class="button">
					{% else %}
						<input type="submit" name="save|{{entry_type}}" value="{{button_unpublish}}" class="button">
					{% endif %}
					<input type="submit" name="preview|{{entry_type}}" value="{{button_preview}}" class="button">
					<input type="submit" name="publish|{{entry_type}}" value="{{button_publish}}" class="button">
				{% endif %}
			{% else %}
				<input type="submit" name="save|{{entry_type}}" value="{{button_save_as_draft}}" class="button">
				<input type="submit" name="preview|{{entry_type}}" value="{{button_preview}}" class="button">
				<input type="submit" name="publish|{{entry_type}}" value="{{button_publish}}" class="button">
			{% endif %}
			</center>
			
		</form>
		</div>
		</div>
	{% include "../common_footer.html" %}
	</body>
</html>
